<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>ol.Overlay实现标注</title>
    <link rel="stylesheet" href="../v6.4.3/css/ol.css">
    <link rel="stylesheet" href="css/overlayMarker.css">
  </head>
  <body>
    <div id="map" style="height: 500px;"></div>
    <div id="beijing">
      <a href="https://baidu.com"></a>
    </div>
    
    <script src="../v6.4.3/build/ol.js"></script>
    <script>
      const El_beijing = document.getElementById('beijing')
      const mapLayer = new ol.layer.Tile({
        source: new ol.source.Stamen({
          layer: 'terrain'
        })
      })
      const mapView = new ol.View({
        center: [12956325, 4851028],
        zoom: 2
      })
      const marker = new ol.Overlay({
        position: [12956325, 4851028], //标注位置
        positioning: 'center-center', //标注相对于锚点的方位
        element: El_beijing
      })
      const map = new ol.Map({
        target: 'map',
        layers: [mapLayer],
        view: mapView
      })

      //将Overlay对象加入 map
      map.addOverlay(marker)

    </script>
  </body>
</html>
